package test;

import static org.junit.Assert.*;
import org.junit.Test;
import LevelParser.levelParser;


public class parser_unit {
    @Test
    public void test()
			{
				levelParser parser = new levelParser("levelMap","res/level_map.xml");
                assertTrue("Xml open failed", parser != null);
                
				String[] att = {"levelnumber"};
				String[][] atts = parser.GetAttributes("level",att);
                assertTrue("Parsing error", atts[0][0].equalsIgnoreCase("1"));
                
                String[] enetypes = parser.GetSameNameAttributes("enemyTypes","Type");

                assertTrue("Parsing error", enetypes[0].equalsIgnoreCase("EnemyDummy"));
			}
    
    @Test
    public void test2()
			{
				levelParser parser = new levelParser("levelMap","res/level_map.xml");
                assertTrue("Xml open failed", parser != null);
                
				String[] att = {"scenery"};
				String[][] atts = parser.GetAttributes("level",att);
                assertTrue("Parsing error", atts[0][0].equalsIgnoreCase("1"));
			}
    
    @Test
    public void test3()
			{
				levelParser parser = new levelParser("levelMap","res/level_map.xml");
                assertTrue("Xml open failed", parser != null);
                
				String[] att = {"music"};
				String[][] atts = parser.GetAttributes("level",att);
                assertTrue("Parsing error", atts[0][0].equalsIgnoreCase("res/calm.ogg"));
			}
    
    @Test
    public void test4()
			{
				levelParser parser = new levelParser("levelMap","res/level_map.xml");
                assertTrue("Xml open failed", parser != null);
                
				String[] att = {"scenery"};
				String[][] atts = parser.GetAttributes("level",att);
                assertTrue("Parsing error", atts[0][0].equalsIgnoreCase("1"));
			}
    
    @Test
    public void test5()
			{
				levelParser parser = new levelParser("levelMap","res/level_map.xml");
                assertTrue("Xml open failed", parser != null);
                
				String[] att = {"levelnumber"};
				String[][] atts = parser.GetAttributes("level",att);
                assertTrue("Parsing error", atts[0][0].equalsIgnoreCase("1"));
			}
    
    @Test
    public void test6()
			{
				levelParser parser = new levelParser("levelMap","res/level_map.xml");
                assertTrue("Xml open failed", parser != null);
                
				String[] att = {"levelnumber"};
				String[][] atts = parser.GetAttributes("level",att);
                assertTrue("Parsing error", atts[0][0].equalsIgnoreCase("1"));
                
                String[] enetypes = parser.GetSameNameAttributes("enemyTypes","Type");

                assertTrue("Parsing error", enetypes[0].equalsIgnoreCase("EnemyDummy"));
			}
    
    @Test
    public void test7()
			{
				levelParser parser = new levelParser("levelMap","res/level_map.xml");
                assertTrue("Xml open failed", parser != null);
                
				String[] att = {"levelnumber"};
				String[][] atts = parser.GetAttributes("level",att);
                assertTrue("Parsing error", atts[0][0].equalsIgnoreCase("1"));
                
                String[] enetypes = parser.GetSameNameAttributes("enemyTypes","Type");

                assertTrue("Parsing error", enetypes[0].equalsIgnoreCase("EnemyDummy"));
			}
    
    @Test
    public void test8()
			{
				levelParser parser = new levelParser("levelMap","res/level_map.xml");
				
				parser.showXML();
				
				//Getting <enemy> tags attributes
				
				String[] enemyattributes = {"id","type","coordX","coordY","timeOffset"};
				
				String[][] atts = parser.GetAttributes("enemy",enemyattributes);
				
				assertTrue("Parsing error", atts[1][1].equalsIgnoreCase("elf"));
			}
}
